package com.yunhe.rentcars.pro.service.rent.impl;

import com.yunhe.rentcars.commons.dto.Pageable;
import com.yunhe.rentcars.pro.dao.rent.CarOrderDao;
import com.yunhe.rentcars.pro.entity.rent.CarOrder;
import com.yunhe.rentcars.pro.service.rent.CarOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CarOrderServiceImpl implements CarOrderService {

    @Autowired
    private CarOrderDao carOrderDao;


    @Override
    public void saveCarOrder(CarOrder carOrder) {
        carOrderDao.saveCarOrder(carOrder);
    }

    @Override
    public void updateCarOrder(CarOrder carOrder) {
        carOrderDao.updateCarOrder(carOrder);
    }

    @Override
    public void updateOrderstate(CarOrder carOrder) {
        carOrderDao.updateOrderstate(carOrder);
    }

    @Override
    public void deleteCarOrder(Long id) {
        carOrderDao.deleteCarOrder(id);
    }

    @Override
    public CarOrder findCarOrder(Long id,String orderid) {
       return carOrderDao.findCarOrder(id,orderid);
    }

    @Override
    public Pageable<CarOrder> findList(CarOrder carOrder, Integer offset, Integer limit) {
        Pageable<CarOrder> pageable = new Pageable<>();
        Integer count = carOrderDao.findCount(carOrder);
        List<CarOrder> rows = null;
        if(count > 0) {
            rows = carOrderDao.findList(carOrder,offset,limit);
        }
        pageable.setRows(rows);
        pageable.setTotal(count);
        return pageable;
    }




}
